package com.itao.springboot.controller;

import com.itao.springboot.annotation.BusinessAction;
import com.itao.springboot.annotation.LogAnn;
import com.itao.springboot.bean.LogTestModel;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sjt
 * @Date 2024/12/26 10:15
 */
@RestController
public class SpelController {

    @Value("#{user.getName()}")
    private String name;

    @Value("#{@user.getName()}")
    private String name2;

    @Value("#{${hello:user}.getName()}")
    private String name1;

    @Value("#{@${hello:'user'}.getName()}")
    private String name3;


    @PostMapping("/getName")
    public String getName() {
        return name + "-" + name1 + "-" + name2 + "-" + name3;
    }


    @PostMapping("/log")
    @LogAnn(operator = "#logTestModel.userName", bizNo = "#logTestModel.orderId", action = BusinessAction.OTHER)
    public String LogAnn(@RequestBody LogTestModel logTestModel) {
        System.out.println("测试");
        return "success";
    }


    @PutMapping("/put")
    public String put() {
        System.out.println("测试");
        return "success";
    }

}
